package greatestLetter;

import java.util.Arrays;

public class Solution {
    public String greatestLetter(String s) {
        // 大写和小写都出现
        int[] cnt = new int[26]; // 大写和小写都出现 用两位来表示大写和小写
        for (int i = 0; i < s.length(); i++) {
            if(Character.isUpperCase(s.charAt(i))) {
                cnt[Character.toLowerCase(s.charAt(i))-'a'] = cnt[Character.toLowerCase(s.charAt(i))-'a']|2;
            } else {
                cnt[s.charAt(i)-'a'] = cnt[s.charAt(i)-'a']|1;
            }
        }
        System.out.println(Arrays.toString(cnt));
        for (int i = 25; i >=0 ; i--) {
            if(cnt[i] == 3) return (char)(i+'a')+"";
        }
        return "";
    }
}
